#ifndef VEC2D
#define VEC2D

#include <cmath>

class Vec2d {
    public:
        double x;
        double y;
        Vec2d(double new_x, double new_y) { x = new_x; y = new_y; };
        Vec2d(const Vec2d& new_vec) { x = new_vec.x; y = new_vec.y; };
        Vec2d() { x = y = 0.0; };
        double length() { return sqrt(x*x + y*y); };
        Vec2d operator=(const Vec2d& rhs) { x = rhs.x; y = rhs.y; return *this; };
		Vec2d operator+(const Vec2d& rhs) { return Vec2d(this->x + rhs.x, this->y + rhs.y); };
		Vec2d operator+=(const Vec2d& rhs) { x += rhs.x; y += rhs.y; return *this; };
		Vec2d operator-(const Vec2d& rhs) { return Vec2d(this->x - rhs.x, this->y - rhs.y); };
		Vec2d operator-=(const Vec2d& rhs) { x -= rhs.x; y -= rhs.y; return *this; };
        Vec2d operator*(double rhs) { return Vec2d(x*rhs, y*rhs); }; // scalar multiplication
		Vec2d operator*=(double rhs) { x *= rhs; y *= rhs; return *this; };
        Vec2d operator/(double rhs) { return Vec2d(x/rhs, y/rhs); };
		Vec2d operator/=(double rhs) { x /= rhs; y /= rhs; return *this; };
};

#endif
